import i18n from '@/lang'
import Vue from "vue";
export const modelListTbColumns = [
  {
    title: '品牌',
    dataIndex: 'model.company',
    width: 80,
    special: true,
    scopedSlots: { customRender: 'company' }
  },
  {
    title: i18n.t('brandName'),
    dataIndex: 'model.brandName',
    width: 140,
    scopedSlots: { customRender: 'brandName' }
  },
  {
    title: i18n.t('modelName'),
    dataIndex: 'model.name',
    width: 140,
    special: true,
    scopedSlots: { customRender: 'model' }
  },
  {
    title: i18n.t('modelCode'),
    dataIndex: 'model.code',
    width: 140,
    scopedSlots: { customRender: 'modelCode' }
  },
  // {
  //   title: '年款',
  //   dataIndex: 'model.makeYear',
  //   width: 70,
  //   scopedSlots: { customRender: 'makeYear' }
  // },
  // {
  //   title: i18n.t('stereotype'),
  //   dataIndex: 'model.trimLevel',
  //   width: 100,
  //   scopedSlots: { customRender: 'stereotype' }
  // },
  // {
  //   title: i18n.t('stereotypeCode'),
  //   dataIndex: 'model.trimLevelCode',
  //   width: 100,
  //   scopedSlots: { customRender: 'stereotypeCode' }
  // },
  // {
  //   title: '动力类型',
  //   dataIndex: 'model.power',
  //   width: 100,
  //   special: true,
  //   scopedSlots: { customRender: 'power' }
  // },
  {
    title: '销售区域',
    dataIndex: 'model.saleArea',
    width: 100,
    special: true,
    scopedSlots: { customRender: 'saleArea' }
  },
  {
    title: '配置车型',
    dataIndex: 'name',
    width: 200,
    scopedSlots: { customRender: 'name' }
  },
  {
    title: '配置车型代码',
    dataIndex: 'code',
    width: 130,
    scopedSlots: { customRender: 'code' }
  },
  // {
  //   title: '公告型号',
  //   dataIndex: 'publishCode',
  //   width: 100,
  //   scopedSlots: { customRender: 'publishCode' }
  // },
  {
    title: i18n.t('relatedECU'),
    width: 100,
    key: 'relatedECU',
    special: true,
    scopedSlots: { customRender: 'ecuList' }
  },
  {
    title: i18n.t('managedServices'),
    key: 'managedServices',
    width: 100,
    special: true,
    scopedSlots: { customRender: 'managedServices' }
  },
  {
    title: i18n.t('timeOfCreation'),
    dataIndex: 'createTime',
    width: 120,
    sorter: true,
    special: true,
    scopedSlots: { customRender: 'createTime' }
  },
  {
    title: i18n.t('creator'),
    dataIndex: 'createBy',
    width: 100,
    scopedSlots: { customRender: 'creator' }
  },
  {
    title: '数据来源',
    dataIndex: 'dataFrom',
    width: 100,
    special: true,
    scopedSlots: { customRender: 'dataFrom' }
  },
  {
    title: '确认状态',
    width: 100,
    special: true,
    customRender: (text, record, index) => {
      if (record.dataFrom !== 'EXTERNAL') {
        return '已确认';
      }
      if (record.model.company !== 'UNKNOWN' && record.model.name !== record.model.code) {
        return '已确认';
      }
      return '未确认';
    },
  },
  {
    title: i18n.t('operation'),
    dataIndex: 'action',
    width: 280,
    special: true,
    fixed: 'right',
    scopedSlots: { customRender: 'action' }
  }
]
export const relatedVehicleTbColumns = [
  {
    key: 'vin',
    title: 'VIN',
    dataIndex: 'vin',
    width: 200,
    scopedSlots: { customRender: 'updateLevel' }
  },
  {
    key: 'vehicleType',
    title: i18n.t('vehicleType'),
    dataIndex: 'vehicleType',
    special: true,
    width: 150,
    scopedSlots: { customRender: 'vehicleType' }
  },
  {
    title: i18n.t('productionYear'),
    dataIndex: 'productionTime',
    key: 'productionTime',
    special: true,
    width: 200,
    scopedSlots: { customRender: 'productionTime' }
  },
  {
    title: i18n.t('province'),
    dataIndex: 'province',
    key: 'province',
    special: true,
    width: 200,
    scopedSlots: { customRender: 'province' }
  },
  {
    key: 'manufacturer',
    title: i18n.t('productionPlant'),
    dataIndex: 'manufacturer',
    width: 200,
    customRender: (text, record, index) => {
      return Vue.$store.getters.getDictCodeObj('manufacturerDictCode')[text] || text;
    },
    scopedSlots: { customRender: 'manufacturer' }
  }
]

export const relatedEcuTbColumns = [
  {
    dataIndex: 'ecuModuleId',
    title: i18n.t('partNumber'),
    scopedSlots: { customRender: 'partNumber' },
    width: 120
  },
  {
    dataIndex: 'ecuSoftwareCode',
    key: 'ecuSoftwareCode',
    title: i18n.t('softwareCoding'),
    scopedSlots: { customRender: 'ecuSoftwareCode' },
    width: 120
  },
  {
    title: i18n.t('partName'),
    dataIndex: 'ecuName',
    key: 'partName',
    scopedSlots: { customRender: 'partName' },
    width: 120
  },
  {
    title: 'ECU' + i18n.t('latestVersion'),
    dataIndex: 'lastVersion',
    scopedSlots: { customRender: 'lastVersion' },
    width: 150
  },
  {
    title: i18n.t('configurationFile'),
    dataIndex: 'ecuConfigDid',
    scopedSlots: { customRender: 'ecuConfigDid' },
    width: 150
  },
  {
    title: i18n.t('configurationFileCode'),
    dataIndex: 'configSoftwareCode',
    scopedSlots: { customRender: 'configSoftwareCode' },
    width: 150
  },
  {
    title: i18n.t('configFile') + i18n.t('latestVersion'),
    dataIndex: 'lastConfigVersion',
    scopedSlots: { customRender: 'lastConfigVersion' },
    width: 130
  },
  {
    title: i18n.t('diagnosisID'),
    dataIndex: 'ecuDiaId',
    scopedSlots: { customRender: 'diagnosisId' },
    width: 100
  },
  {
    title: i18n.t('softDid'),
    dataIndex: 'ecuDid',
    scopedSlots: { customRender: 'softDid' },
    width: 100
  },

]
export const relatedServiceTbColumns = [
  {
    title: i18n.t('operation'),
    special: true,
    scopedSlots: { customRender: 'versionDepend' },
    width: 100,
    fixed: 'right'
  }
]
export const managedServicesColumns = [
  {
    title: i18n.t('publishState'),
    dataIndex: 'publishStatus',
    width: 140,
    scopedSlots: { customRender: 'publishStatus' }
  },
  {
    title: i18n.t('operation'),
    key: 'operation',
    width: 100,
    special: true,
    fixed: 'right',
    scopedSlots: { customRender: 'action' }
  }
]
export const commonServicesColumns = [
  {
    title: i18n.t('serviceCode'),
    dataIndex: 'serviceCode',
    width: 160,
    scopedSlots: { customRender: 'serviceCode' }
  },
  {
    title: i18n.t('serviceName'),
    dataIndex: 'serviceName',
    width: 160,
    scopedSlots: { customRender: 'serviceName' }
  },
  {
    title: i18n.t('fwgsy'),
    dataIndex: 'serviceBelong',
    width: 100,
    special: true,
    scopedSlots: { customRender: 'fwgsy' }
  },
  {
    title: i18n.t('fwfl'),
    dataIndex: 'serviceCategory',
    width: 100,
    special: true,
    scopedSlots: { customRender: 'fwfl' }
  },
  // {
  //   title: i18n.t('presetOrNot'),
  //   dataIndex: 'enableState',
  //   width: 100,
  //   special: true,
  //   scopedSlots: { customRender: 'yesNoType' }
  // },
  // {
  //   title: i18n.t('whetherSold'),
  //   dataIndex: 'saleState',
  //   special: true,
  //   width: 100,
  //   scopedSlots: { customRender: 'yesNoType' }
  // },
  // {
  //   title: i18n.t('whetherActivated'),
  //   dataIndex: 'activeState',
  //   special: true,
  //   width: 100,
  //   scopedSlots: { customRender: 'yesNoType' }
  // },
  {
    title: '销售方式',
    dataIndex: 'saleState',
    special: true,
    width: 100,
    scopedSlots: { customRender: 'saleState' }
  },
  {
    title: '是否需激活',
    dataIndex: 'activeState',
    special: true,
    width: 100,
    scopedSlots: { customRender: 'yesNoType' }
  },
  {
    title: i18n.t('needToLearn'),
    dataIndex: 'needStudy',
    width: 100,
    special: true,
    scopedSlots: { customRender: 'yesNoType' }
  }
]

export const editDependsColumns = [
  {
    title: i18n.t('partNumber'),
    dataIndex: 'ecuModuleId',
    width: 100,
    scopedSlots: { customRender: 'partNumber' }
  },
  {
    title: i18n.t('partName'),
    dataIndex: 'name',
    width: 100,
    scopedSlots: { customRender: 'partName' }
  },
  {
    title: i18n.t('softwareCoding'),
    dataIndex: 'softwareCode',
    width: 100,
    scopedSlots: { customRender: 'softwareCoding' }
  },
  {
    title: i18n.t('diagnosisID'),
    dataIndex: 'ecuDiaId',
    width: 100,
    scopedSlots: { customRender: 'diagnosisID' }
  },
  {
    title: i18n.t('最低运行版本'),
    dataIndex: 'dependSoftwareCode',
    width: 100,
    special: true,
    scopedSlots: { customRender: 'minDependencyVersion' }
  }
]

export const supplierViewModalColumns = [
  {
    title: `${i18n.t('supplier')}ID`,
    dataIndex: 'supplierId',
    width: 200,
    scopedSlots: { customRender: 'supplierId' }
  },
  {
    title: i18n.t('supplierName'),
    dataIndex: 'supplierName',
    width: 200,
    scopedSlots: { customRender: 'supplierName' }
  }

]

export const managedServicesRowMenus = [
  {
    // 加入管理
    title: i18n.t('addManagement'),
    key: 'addManagement',
    disabled (record) {
      // 除了未管理
      return record.publishStatus !== -1
    }
  },
  // {
  //   // 编辑依赖
  //   title: i18n.t('editDependencies'),
  //   key: 'editDependencies',
  //   // 不能操作（未管理 审核中 已通过 已发布）
  //   disabled (record) {
  //     // eslint-disable-next-line max-len
  //     return record.publishStatus === -1 || record.publishStatus === 3 || record.publishStatus === 6 || record.publishStatus === 20
  //   }
  // },
  // 编辑服务
  {
    title: i18n.t('editService'),
    key: 'editService',
    // 不能操作（未管理 审核中 已通过 已发布）
    disabled (record) {
      // eslint-disable-next-line max-len
      return record.publishStatus === -1 || record.publishStatus === 3 || record.publishStatus === 6 || record.publishStatus === 20
    }
  },
  // 查看依赖
  // {
  //   title: i18n.t('viewDependencies'),
  //   key: 'viewDependencies',
  //   // 不能操作（未管理 待发布 已驳回 已撤回）
  //   disabled (record) {
  //     // eslint-disable-next-line max-len
  //     return record.publishStatus === -1 || record.publishStatus === 0 || record.publishStatus === 5 || record.publishStatus === 7
  //   }
  // },
  // 查看审核
  {
    title: i18n.t('viewAudit'),
    key: 'viewAudit',
    // 不能操作（未管理 待发布  已撤回）
    disabled (record) {
      return record.publishStatus === -1 || record.publishStatus === 0 || record.publishStatus === 7
    }
  },
  // 撤回发布
  {
    title: i18n.t('withdrawReleases'),
    key: 'withdrawReleases',
    // 除了已发布
    disabled (record) {
      return record.publishStatus !== 20
    }
  },
  // 发布服务
  {
    title: i18n.t('publishService'),
    key: 'publishService',
    // 除了已通过
    disabled (record) {
      return record.publishStatus !== 6
    }
  }
]
export const configEcuColum = [{
  title: i18n.t('partName'),
  dataIndex: 'ecuName',
  scopedSlots: {
    customRender: 'partName'
  },
  width: 140
}, {
  title: i18n.t('partNumber'),
  dataIndex: 'ecuModuleId',
  scopedSlots: {
    customRender: 'partNumber'
  },
  width: 140
}, {
  title: i18n.t('softwareCoding'),
  dataIndex: 'softwareCode',
  scopedSlots: {
    customRender: 'softwareCoding'
  },
  width: 140
},
{
  slots: { title: 'dependentGroupingColumn' },
  dataIndex: 'groupNo',
  scopedSlots: {
    customRender: 'dependentGrouping'
  },
  width: 100,
  special: true
},
// {
//   slots: { title: 'isRollbackColumn' },
//   dataIndex: 'groupRollback',
//   scopedSlots: {
//     customRender: 'isRollback'
//   },
//   width: 120,
//   special: true
// },
{
  slots: { title: 'updateOrderColumn' },
  dataIndex: 'groupUpgradeNo',
  scopedSlots: {
    customRender: 'updateOrder'
  },
  width: 100,
  special: true
}, {
  title: i18n.t('配置'),
  key: 'ecuAssembleType',
  dataIndex: 'ecuAssembleType',
  scopedSlots: { customRender: 'ecuAssembleType' },
  width: 140
}, {
  title: i18n.t('装配车辆VIN'),
  key: 'vinList',
  dataIndex: 'vinList',
  scopedSlots: { customRender: 'vinList' },
  width: 140
},{
  title: i18n.t('operation'),
  dataIndex: 'action',
  width: 150,
  special: true,
  fixed: 'right',
  scopedSlots: { customRender: 'action' }
}]
